//
//  NSString+Base64.m
//  ZhongXiJin
//
//  Created by apple on 2017/8/1.
//  Copyright © 2017年 NARA. All rights reserved.
//

#import "NSString+Base64.h"

@implementation NSString (Base64)

- (NSString *)base64EncodedString;
{
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
    return [data base64EncodedStringWithOptions:0];
}

- (NSString *)base64DecodedString
{
    NSData *data = [[NSData alloc]initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
    
    return [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
}

/**
 *  转换为Base64编码
 */
- (NSData *)base64EncodedData
{
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];

    return data;
}
/**
 *  将Base64编码还原
 */
- (NSData *)base64DecodedData
{
    NSData *data = [[NSData alloc]initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
    return data;
}


@end
